﻿using Rapid.Entity.Basic;
using Rapid.MvcExtension.Controllers;
using Rapid.Core.Aop;
using Rapid.Utility.Helper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Rapid.MvcApplication.Areas.Manage.Controllers
{
    public class UserDepartmentPostController : ManageController
    {
        public ActionResult List(string _menuid)
        {
            return View(ServiceFactory.BasicMenu.Get(_menuid));
        }

        public ActionResult Page(string id, string userid)
        {
            BasicUserDepartmentPost model = new BasicUserDepartmentPost();

            if (string.IsNullOrEmpty(id))
            {
                model.UserID = userid;
            }
            else { model = ServiceFactory.BasicUserDepartmentPost.Get(id); }

            return View(model);
        }

        public string Grid(string userid)
        {
            return JsonHelper.Serialize(ServiceFactory.BasicUserDepartmentPost.GetByUserID(userid));
        }

        public string Save(BasicUserDepartmentPost entity)
        {
            return ServiceFactory.BasicUserDepartmentPost.Save(entity).Serialize();
        }

        public string Remove(string id)
        {
            return ServiceFactory.BasicUserDepartmentPost.Delete(id).Serialize();
        }
    }
}
